package may.test_5_29;

import java.util.Map;
import java.util.Scanner;

public class TestMain {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long q = scanner.nextLong();
        long h = 0;
        long count = 0;
        for (int i = 0; i < n; i++) {
            long a = scanner.nextInt();
            if(a == 0) {
                count++;
            }
            h += a;
        }
        int[] maxs = new int[(int)q];
        int[] mins = new int[(int)q];
        for (int i = 0; i < q; i++) {
            int l = scanner.nextInt();
            int r = scanner.nextInt();
            maxs[i] = Math.max(l,r);
            mins[i] = Math.min(l,r);
        }
        for (int i = 0; i < q; i++) {
            System.out.print(h + (count * mins[i]) + " ");
            System.out.println(h + (count * maxs[i]));
        }
    }
}
